package main.client;

import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;

public class TableContent extends Composite {	
	/**
	 * Constructor
	 * Creates contents for the main page table
	 * @param item
	 */
	public TableContent(Item item)
	{
		Label name = new Label(item.getName());
		Label catName = new Label(item.getCategoryName());
		VerticalPanel vPanel = new VerticalPanel();
		catName.setStyleName("mediumTitle");
		
		vPanel.add(catName);
		if (item.getImage() != null) {
		String[] split1 = item.getImage().split("/");
		Image image = new Image(split1[split1.length-2] + "/" + split1[split1.length-1]);
		image.setWidth("100px");
		vPanel.add(image);
		}
		
		
		vPanel.add(name);
		
		name.setTitle(item.getDescription());
		vPanel.setSize("100px", "100px");
		vPanel.setStyleName("table");
		initWidget(vPanel);
	}
}
